package game
{
	import com.yzy.models.SetLibs;
	
	import control.Control;
	
	import effect.Effect;
	
	import game.bejeweled.BejeweledBlock;
	
	import starling.core.Starling;
	import starling.display.Image;
	import starling.display.MovieClip;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;
	
	public class Game extends Sprite
	{
		public function Game()
		{
			super();
			this.addEventListener(Event.ADDED_TO_STAGE,onAdded);
		}
		
		private function onAdded(e:starling.events.Event):void
		{
			var profileXml:XML=new XML(String(SetLibs.getLibsData("Profile")));
			var bjBlock:BejeweledBlock=new BejeweledBlock(profileXml.Resources.bejeweled);
			//
			
			var bgimage:Image=new Image(Texture.fromBitmapData(SetLibs.getBitmapData("game_bg")));
			this.addChild(bgimage);
			
			
			
			var monsterxml:XML=new XML(String(SetLibs.getLibsData("monster1")));
			var monsterTexture:Texture=Texture.fromBitmapData(SetLibs.getBitmapData("monster1"));
			var stextureAtlas:TextureAtlas=new TextureAtlas(monsterTexture,monsterxml);
			var frames:Vector.<Texture>=stextureAtlas.getTextures("m");
			//
			var movieclip:MovieClip=new MovieClip(frames,4);
			trace("frames.length="+frames.length)
			trace(movieclip.isPlaying)
			
			movieclip.play();
			movieclip.x=580;
			movieclip.y=160;
			this.addChild(movieclip);
			Starling.juggler.add(movieclip);
			
			
			Control.instant.initGameCtrl();
			this.addChild(Effect.instant);
			this.addChild(bjBlock);
		}
	}
}